#include "gtest/gtest.h"

#include "BreakPointService.h"
#include "BreakPointState.h"


#include "BreakPointState.h"
TEST(BreakPointStatusTest, use){
    IBreakPointState * state = new BreakPointState;
    ASSERT_TRUE(state->isEnd());
    ASSERT_FALSE(state->isInited());
    ASSERT_FALSE(state->isConnected());
    ASSERT_FALSE(state->isLogined());
    ASSERT_FALSE(state->isDisconnected());

    ASSERT_EQ(0, state->toInited(nullptr));
    ASSERT_EQ(0, state->toConnected(nullptr));
    ASSERT_EQ(0, state->toLogined(nullptr));
    ASSERT_EQ(0, state->toDisconnected(nullptr));
    ASSERT_EQ(0, state->toEnd(nullptr));

    state->log(std::cout);
    delete state;
}

#include "BreakPointStateSST.h"

TEST(BreakPointStateSSTTest, use){
    IBreakPointState * state = new BreakPointStateSST;
    ASSERT_TRUE(state->isEnd());
    ASSERT_FALSE(state->isInited());
    ASSERT_FALSE(state->isConnected());
    ASSERT_FALSE(state->isLogined());
    ASSERT_FALSE(state->isDisconnected());

    ASSERT_EQ(0, state->toInited(nullptr));
    ASSERT_EQ(0, state->toConnected(nullptr));
    ASSERT_EQ(0, state->toLogined(nullptr));
    ASSERT_EQ(0, state->toDisconnected(nullptr));
    ASSERT_EQ(0, state->toEnd(nullptr));

    state->log(std::cout);
    delete state;
}




TEST(BreakPointServiceStatusTest, startAndStop){

    BreakPointService service;

    ASSERT_EQ(0, service.start());

    ASSERT_EQ(0, service.connected());

    ASSERT_EQ(0, service.receivedLoginResp("login-rsp"));

    ASSERT_EQ(0, service.timeout());
    ASSERT_EQ(0, service.receivedBreakPointResp("breakpoint-rsp"));

    ASSERT_EQ(0, service.receivedNormalResp("normal"));

    ASSERT_EQ(0, service.disconnected());

    ASSERT_EQ(0, service.stop());
}


TEST(BreakPointServiceStatusTest, errorUse){
    BreakPointService service;
    ASSERT_EQ(0, service.start());


    ASSERT_EQ(-1, service.disconnected()); // switch status, check failed 

    ASSERT_EQ(0, service.connected()); //switch OK 

    ASSERT_EQ(0, service.stop());
}

